class code6 {
    //字母异位词分组
    public List<List<String>> groupAnagrams(String[] strs) {
        Map<String,List<String>> hash =  new HashMap<>();
        for(String x:strs) {
            //1.排序
            char[] tmp = x.toCharArray();
            Arrays.sort(tmp);
            String key = new String(tmp);
            //2.分组
            if(!hash.containsKey(key)) {
                hash.put(key,new ArrayList());
            }
            hash.get(key).add(x);

        }
        return new ArrayList(hash.values());
    }
}